#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main1()
{
	int arr[10] = { 30,40,50,60,70,90,10,20,40,60 };
	int max = arr[0];
	for (int i = 1; i < 10; i++)
	{
		if (max < arr[i])
			max = arr[i];
	}
	printf("max=%d", max);
	return 0;
}


int main2()
{
	double sum = 0;
	int flag = 1;
	for (int i = 1; i <= 100; i++)
	{
		sum += 1.0 / (i * flag);
		flag = -flag;
	}
	printf("%lf", sum);
	return 0;
}


int main()
{
	int a = 0;
	int b = 0;
	scanf("%d%d", &a, &b);
	int c = a % b;
	while(c != 0)
	{
		a = b;
		b = c;
		c = a % b;
	}
	printf("%d\n", b);
	return 0;
}